<%--
 *  File:    NotesEdit.jsp
 *  @Author: Vector mao
 *  Date:    2/19/2002 13:45
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.foundation.DefaultParams" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  	Category cat = Category.getInstance("jsp.NotesEdit");
  	//init param
  	String strModuleName = "BIEE";
	String privilegeCode = "Z0402,L301,H0258";
    String contextPath = request.getContextPath();
%>
<%
  	HashMap userInfo = (HashMap)session.getAttribute("userinfo");
    String strIsDefault = null;
    String paraIsDefault = "";
	String isTdNeed = "td-text";
    if("Y".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
    String viewflag = "";

    if(request.getParameter("viewflag")!=null&&"view".equals((String)request.getParameter("viewflag"))) {

          viewflag = "view";
    }
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%//int LangNums = ConstantProp.multiLangNumber;%>
<html>

<head>
<title>NotesEdit</title>
<PageFlow:CheckPageFlow pageName="p_agreementattachment"/>
<%@ include file="/inc/InitEdit.inc" %>
<%@ include file="/inc/SummaryDivision.inc"%>

<%
Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
if (totalsummary == null)
    totalsummary = new Vector();
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js">
</script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js">
</script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js">
</script>
<script>
function page_done()
{    
	 if(getLength(cform.title.value)>128)
	 {
      alert("<%= message.getMessageDesc("LENGTH_MUST_LESSTHAN",label.getLabelName("L_TitleCN",false),"128") %>");
	    return;
	 }
	  if(!checkNull(document.cform)) return;
	  
	  
    if(document.cform.ispublic0.checked == true)
      document.cform.ispublic.value = "Y";
    else
      document.cform.ispublic.value = "N";
    var opts = cform.picturenames.options;
    var hiddenpname = "";
    if (opts!=null)
    for (var i = 0 ; i<opts.length;i++)
      hiddenpname += "<input type=hidden name=newpictures value="+opts[i].value +">";
    hide.innerHTML = hiddenpname;
    
    MLCSTransform(document.cform);
    emptyToNull(document.cform);  
  
  	document.cform.actionname.value = "done";
  	document.cform.target = "_parent";
  	isRunning = true;
  	document.cform.submit();
}
function choosepublic()
{
 if (document.cform.ispublic.value == "Y")
 {
   document.cform.ispublic.value = "N";
 }else
 {
   document.cform.ispublic.value = "Y";
 }
}
   
function deloption()
{
    var opts = cform.picturenames.options;
    if (opts!=null)
    for (var i = opts.length-1 ; i>=0;i--)
    {
      if (opts[i].selected == true)
        opts.remove (i);
    }

}
function page_add()
{
      if(!checkForm(document.cform))return;
      //文件路径 、校验格式
      var pname = ""+cform.picture.value;
      if (pname==""){
        alert(replaceString("<%=message.getMessageDesc("VALUE_NOT_NULL")%>","%s","<%=label.getLabelName("L_Maccessory")%>".replace("\'","'")));
        cform.picture.focus();
        return;
      }
      var iLastPoint=pname.lastIndexOf(".");
      if(iLastPoint!=-1)
  	   cform.filesuffix.value=pname.substring( iLastPoint+1,pname.length);
  	  var iLastPoint1=pname.lastIndexOf("\\");
       if(iLastPoint1!=-1)
       cform.picturestr.value=pname.substring( iLastPoint1+1,iLastPoint)+"<%=Calendar.getInstance().getTimeInMillis()   %>";
      var re = /.txt$|.doc$|.docx$|.xls$|.xlsx$|.vsd$|.pdf$|.ppt$|.zip$|.rar$|.bmp$|.jpg$|.jpeg$|.tiff$|.gif$|.pcx$|.tga$|.exif$|.fpx$|.svg$|.psd$|.cdr$|.pcd$|.dxf$|.ufo$|.eps$|.ai$|.raw$/ig;
      if(pname.toUpperCase().match(re) == null)
      {
        alert("<%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Maccessory",false)) %>");
        return;
      }  
      if (pname.indexOf("\\")!=-1)
        pname = pname.substring(pname.lastIndexOf("\\")+1,pname.length);
      //文件名称
      if (cform.picturename.value=="")
        cform.picturename.value = pname;
      if(cform.picturename.value.toUpperCase().match(re) == null)
      {
        if(pname.lastIndexOf(".") != -1)
          cform.picturename.value += pname.substring(pname.lastIndexOf("."));
        <%--[SCRIPT]  alert("<#%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Picture",false)) %#>");  [SCRIPT]--%>
        <%--[SCRIPT]  return;  [SCRIPT]--%>
      }  
      if (getLength(cform.picturename.value)>64)
      {
		    alert("<%= message.getMessageDesc("LENGTH_MUST_NOT_EQUAL", label.getLabelName("L_Name",false),"64") %>" );
		    return;
      }
  	cform.actionname.value = "addpic";
  	cform.target = "_self";
  	isRunning = true;
  	cform.submit();

}
function page_delete(){
	if(nullChecked(document.cform.deleteids,"<%=JspHelper.filterNull(totalsummary.size())%>"))
	  {
	    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
	    return;
	  }
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE")%>") ) 
	    return;
	    var frm = document.cform;
	    frm.actionname.value = "delpic";
		frm.target = "_self";
		isRunning = true;
		frm.submit();
}
var popwindow;
function page_mulilang(name,label,num,need)
{
  var zmylagreementattachmentid=document.cform.zmylagreementattachmentid.value;
  if(popwindow!=null)
    popwindow.close();
  var strurl="<%=contextPath%>/common/Lang.jsp?<%= OvalTools.randomURL() %>&form=cform&module=BIEE&mlctype="+label+"&nativelanguage="+need+"&schema=ovnoteslang&entityid="+zmylagreementattachmentid+"&entitytype="+name+"&contentid=noteslangid&colindex="+num;
  var strStatus= "height=250, width=250,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
  popwindow=window.open(strurl, "newwindow",strStatus);
}

function selectFile()
{
  var val = cform.picture.value;
  var fn = val.substring(val.lastIndexOf('\\')+1,val.length);
  if(fn.length == val.length)
    fn = val.substring(val.lastIndexOf('\/')+1,val.length);
  cform.picturename.value=fn;
}
function page_download(name)
{
	cform.columnname.value=name;
	cform.target="cform";
	cform.actionname.value="download";
	cform.target = "_self";
	isRunning = true;
    cform.submit();
}
function page_back()
{  
  parent.location.href = "AgreementManagement.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault )%>";
}
</script>
</head>
<body>

	<%--------------------------------------  hidden form variant   --%>
	<form name="cform" method="post" action="<%=contextPath%>/Dispatcher" ENCTYPE="multipart/form-data">
    <input type="hidden" name="pagename" value="p_agreementattachment">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <custom:hidden  property="zmylagreementid"/>
    <custom:hidden  property="filesuffix"/>
    <custom:hidden  property="columnname"/>
    <input type="hidden" name="uploadpath" value="<%=DefaultParams.findParam("uploadfilepath")%>"/>
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td>
				<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
					<%	if(!viewflag.equals("view")){%>
					<tr>
						<td colspan="3" class="td_right">
							<a onclick='page_add()'><custom:button type="2"	label="L_Add" imgsrc="add_btn.gif" border="0" style="width:60" /></a>
							<a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0" style="width:60" /></a>
						</td>
					</tr>
					<%} %>
					<tr class="deepblue-left">
						<td width="5%" class="title_center">&nbsp;</td>
						<td width="30%" class="title_center"><a href="javascript:page_summary('orderby','picturecontent')"><%= label.getLabelName("L_Maccessory") %><%= label.getLabelName("L_Description") %></a><font color="red"><%= label.getLabelName("L_Asterisk") %></font></td>
						<td width="65%" class="title_center"><a href="javascript:page_summary('orderby','picturename')"><%= label.getLabelName("L_Maccessory") %><%= label.getLabelName("L_Name") %></a><font color="red"><%= label.getLabelName("L_Asterisk") %></font></td>
					</tr>
					<%
						int i=0; 
						Integer idx = new Integer(-1);
                        boolean bHasChecked = false;
                        String strClassType = "";
               %>
					<logic:iterate id="onerow" collection="<%=totalsummary%>" indexId="orderid">
              
            <%
					HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
					if(i%2 == 1){
						strClassType = "td-listrom";
					}else{
						strClassType = "";
					}
					i++;
					idx = new Integer(i-1);
			%>
					<tr class="<%=JspHelper.filterNull( strClassType )%>">
						<td class="td_center">
							<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull(tempMap.get("zmylagreementpictureid") )%>" class="checkbox">
						</td>
						<td nowrap>&nbsp;<custom:write name="onerow" property="picturecontent" nbsp="true" /></td>
						<td>
						    <span style="width=80%">
						    <custom:write name="onerow" property="picturename" nbsp="true" />
						    </span>
						    <a onclick="page_download('<custom:write name="onerow" property="newpicturename"/>');">
						     <custom:button type="1" label="L_Download" imgsrc="new.gif" border="0" style="width:60" />
						    </a>
						</td>
						
					</tr>
					</logic:iterate>
					<%	
					//out.print(viewflag);
					if(!viewflag.equals("view")){%>
					<tr  class="title_center">
						<td>&nbsp;</td>
						<td>&nbsp;
						   <custom:textarea name="newhash" property="picturecontent" cols="50" rows="2" command="notnull" label="L_Description"/>
						</td>
						<td>
						   <input type="text" name="picturename" size="18">&nbsp;<%= label.getLabelName("L_Path") %><%= label.getLabelName("L_Colon") %>
                           <input type="file" name="picture" onclick="javascript:picture.focus()" onfocus="javascript:selectFile()" size="22" >
                           <input type="hidden" name="picturestr" >
 						</td>
					</tr>
					<%} %>
					<%@ include file="/inc/SummaryAction.inc"%>
				</table>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="summary_top"></td>
					</tr>
					<tr>
						<td class="td_center">
							<a onclick="page_back();"><custom:button type="1" label="L_Back" imgsrc="new.gif" border="0" style="width:60" /></a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
<span id=hide></span>
</form>
<script language="JavaScript">
<% //if(isnewflag==1){ %>
    document.cform.zmylagreementattachmentname.value = "";
    document.cform.picture.value = "";
 <%//}%>
</script>
</html>


